# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>

_realname=GtkAda
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}-svn
pkgrel=1
pkgver=3.8_r229123P
pkgdesc="GtkAda is a Gtk2+ binding for Ada using the OOP and other features of this programming language"
arch=('any')
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
url="http://libre.adacore.com/tools/gtkada/"
options=('!staticlibs' 'strip')
license=('GPL3' 'custom')
groups=("${MINGW_PACKAGE_PREFIX}")
makedepends=("subversion")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-ada" 
         "${MINGW_PACKAGE_PREFIX}-gtk3")
source=("$_realname::svn+http://svn.eu.adacore.com/anonsvn/Dev/trunk/$_realname/"
        "${_realname}-mingw.patch")
sha1sums=('SKIP' 
          'ca7dcd32bfbfecdcbd923bb2e12dc5b8b0f91305')

pkgver() {
  cd "$srcdir/$_realname"
  local ver="$(svnversion)"
  local gtkada_major="$(grep GTKADA_MAJOR_VERSION= configure.in | cut -d= -f2)"
  local gtkada_minor="$(grep GTKADA_MINOR_VERSION= configure.in | cut -d= -f2)"
  printf "%s" "${gtkada_major}.${gtkada_minor}_r${ver}"
}

prepare()
{
  cd ${srcdir}/$_realname
  patch -p1 -i ${srcdir}/${_realname}-mingw.patch
  autoreconf -fvi
}

build() {
  cd ${srcdir}/$_realname
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --disable-static \
    --with-GL=no
    
    make -C src prep
    # First make fails due to weird mixed pathname issues, just redo works
    make -j1 || make -j1
}

package() {
  cd ${srcdir}/$_realname
  make DESTDIR="$pkgdir" install
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/examples
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname  
  cp -pf ${srcdir}/${_realname}/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
}
